package com.bing.autoconfig;

import com.bing.animal.Cat;
import com.bing.animal.Dog;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.beans.factory.support.GenericBeanDefinition;

public class AnimalBeanDefinitionRegistrar implements BeanDefinitionRegistryPostProcessor {
    @Override
    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
        GenericBeanDefinition gbdCat = new GenericBeanDefinition();
        gbdCat.setBeanClass(Cat.class);

        GenericBeanDefinition gbdDog = new GenericBeanDefinition();
        gbdDog.setBeanClass(Dog.class);

        registry.registerBeanDefinition("cat", gbdCat);
        registry.registerBeanDefinition("dog", gbdDog);
    }

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {

    }
}
